package bishi.wangyileihuo;

import java.util.*;

public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String demo1 = in.nextLine();
        String demo2 = in.nextLine();
        //map记录键出现的次数
        HashMap<Integer,Integer> map = new HashMap<>();
        //mapA记录变化前键和值
        HashMap<Integer,Integer> mapA = new HashMap<>();
        //mapB记录变化后键和值
        HashMap<Integer,Integer> mapB = new HashMap<>();
        demo1 = demo1.substring(1,demo1.length() - 1);
        demo2 = demo2.substring(1,demo2.length() - 1);
        demo1 = demo1.replace(" ","");
        demo2 =demo2.replace(" ","");
        String[] temp1 = demo1.split(",");
        String[] temp2 = demo2.split(",");
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < temp1.length;i++) {
            String[] temp = temp1[i].split(":");
            Integer key = Integer.valueOf(temp[0]);
            Integer value = Integer.valueOf(temp[1]);
            mapA.put(key,value);
            map.put(key,map.getOrDefault(key,0) + 1);
            if(!list.contains(key)) {
                list.add(key);
            }
        }
        for(int i = 0;i < temp2.length;i++) {
            String[] temp = temp2[i].split(":");
            Integer key = Integer.valueOf(temp[0]);
            Integer value = Integer.valueOf(temp[1]);
            mapB.put(key,value);
            map.put(key,map.getOrDefault(key,0) + 1);
            if(!list.contains(key)) {
                list.add(key);
            }
        }
        int add = 0,add2 = 0;
        int del = 0,del2 = 0;
        int change = 0;
        for(int x : list) {
            int value = map.get(x);
            if(value == 1) {
                if(mapA.containsKey(x)) {
                    del = x;
                    del2 = mapA.get(x);
                }else if(!mapA.containsKey(x)){
                    add = x;
                    add2 = mapB.get(x);
                }
            }
            if(value == 2) {
                if(mapA.get(x) != mapB.get(x)) {
                    change = x;
                }
            }
        }

        int change2 =Math.abs((mapA.get(change) - mapB.get(change)));
        System.out.println("{" + add + ": "+add2+"}");
        System.out.println("{" + del + ": "+del2+"}");
        System.out.println("{" + change + ": "+change2+"}");

    }
}
